package org.vacoor.nothing.misc.express.usps.api.address;

import org.vacoor.nothing.misc.express.usps.api.data.UspsAddress;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/**
 * 地址验证响应
 *
 * @author vacoor
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "AddressValidateResponse")
public class ASResponse implements Iterable<UspsAddress> {
    @XmlElement(name = "Address")
    private List<UspsAddress> addresses;

    public List<UspsAddress> getAddresses() {
        return addresses;
    }

    public void setAddresses(List<UspsAddress> addresses) {
        this.addresses = addresses;
    }

    @Override
    public Iterator<UspsAddress> iterator() {
        return null != addresses ? addresses.iterator() : Collections.<UspsAddress>emptySet().iterator();
    }
}
